package com.kazu.general.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author kazu
 * @Date 2023/2/19 16:06
 * @Version 1.0
 */
@SuppressWarnings({"all"})
@Configuration
@MapperScan({"com.kazu.general.mapper"})
public class MybatisPlusConfig {
	
	/*3.5.*配置分页插件*/
	@Bean
	public MybatisPlusInterceptor mybatisPlusInterceptor() {
		MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
		PaginationInnerInterceptor innerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
		/*页数过大，直接去首页*/
		innerInterceptor.setOverflow(true);
		innerInterceptor.setMaxLimit(1000L);
		interceptor.addInnerInterceptor(innerInterceptor);
		return interceptor;
	}
}